<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;

class RegisterController extends Controller
{
    //
    public function are(Request $request)
    {
        $id = $_POST['id'];
        $order = $_POST['data'];
        if($order == 'time')
        {
            $order = 'imagedate';
        }
        $sort = $_POST['sort'];
        if($sort = 1)
        {
            $sort = 'asc';
        }else{
            $sort = 'desc';
        }
        $data = DB::table('image') -> where('categoryid',$id) -> orderBy($order,$sort)  -> paginate(6);
        return view('home.are',['data' => $data,'request' => $request -> all()]);
    }
}
